home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / include / packets.h < prev    next >
C/C++ Source or Header  |  1995-05-17  |  3KB  |  72 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef _PACKETS_H
  21. #define _PACKETS_H
  22.  
  23. #define PutPacket(port,pack) PutMsg((port), (struct Message *)(pack))
  24.  
  25. #define GetPacket(port) ((struct StandardPacket *)GetMsg(port))
  26.  
  27. /***************************************************************************/
  28.  
  29. #define LastResult(f) ((f)->f_sp.sp_Pkt.dp_Res1)
  30.  
  31. #define LastError(f) ((f)->f_sp.sp_Pkt.dp_Res2)
  32.  
  33. /***************************************************************************/
  34.  
  35. #define SendPacket0(fp,port,act) \
  36.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  37.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  38.  
  39. #define SendPacket1(fp,port,act,arg1) \
  40.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  41.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), \
  42.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  43.  
  44. #define SendPacket2(fp,port,act,arg1,arg2) \
  45.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  46.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  47.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  48.  
  49. #define SendPacket3(fp,port,act,arg1,arg2,arg3) \
  50.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  51.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  52.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), \
  53.   PutPacket((fp)->f_fh->fh_Type, &((fp)->f_sp)))
  54.  
  55. #define SendPacket4(fp,port,act,arg1,arg2,arg3,arg4) \
  56.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  57.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  58.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), (fp)->f_sp.sp_Pkt.dp_Arg4 = (arg4), \
  59.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  60.  
  61. /***************************************************************************/
  62.  
  63. #define HANDLER_NIL(fp) (!(fp)->f_fh->fh_Type)
  64.  
  65. #define CTOBPTR(ptr) (((long)(ptr)) >> 2)
  66. #define BTOCPTR(ptr) ((void *)((ptr) << 2))
  67.  
  68. /* this version only works for word-aligned data as you get it from alloca()! */
  69. #define LONG_ALIGN(ptr) ((void *)((((long)(ptr))&3)?((long)ptr)+2:(long)ptr))
  70.  
  71. #endif /* _PACKETS_H */
  72.